<?php

class AddressLogic {

  function save(&$address)
  {
  	$addDao = new AddressDAO();
  	return $addDao->save($address) == 1;
  }

  function load($id)
  {
    $addressDao = new AddressDAO();
    return $addressDao->get($id);
  }

  function findAll()
  {
    $addressDao = new AddressDAO();
    return $addressDao->findWhere("", "state, city, line1");
  }

  function findOrphaned()
  {
  	// TODO This won't work in any MySQL versions before 4.1 because of the subqueries.
  	//   Currently it's unused so it doesn't matter.
  	$addressDao = new AddressDAO();
    return $addressDao->findWhere("not id in (select address_id from contact) and not id in (select address_id from location)");
  }


}

?>
